/*
 * Powered By cuichen
 * Since 2014 - 2017
 */package com.seeyoui.kensite.framework.cms.template.service;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.common.base.service.BaseService;

import java.util.*;

import com.seeyoui.kensite.common.base.domain.EasyUIDataGrid;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;
import com.seeyoui.kensite.common.util.*;
import com.seeyoui.kensite.common.constants.StringConstant;
import com.seeyoui.kensite.framework.cms.template.domain.Template;
import com.seeyoui.kensite.framework.cms.template.persistence.TemplateMapper;

/**
 * Template
 * @author cuichen
 * @version 2.0
 * @since 1.0
 * @date 2017-12-27
 */

@Service
public class TemplateService extends BaseService {
	
	@Autowired
	private TemplateMapper templateMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public Template findOne(String id) throws CRUDException{
		return templateMapper.findOne(id);
	}
	
	/**
	 * 查询数据集合
	 * @param template
	 * @return
	 * @throws CRUDException
	 */
	public List<Template> findList(Template template) throws CRUDException {
		return templateMapper.findList(template);
	}
	
	/**
	 * 查询所有数据集合
	 * @param template
	 * @return
	 * @throws CRUDException
	 */
	public List<Template> findAll(Template template) throws CRUDException {
		return templateMapper.findAll(template);
	}
	
	/**
	 * 查询数据总数
	 * @param template
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(Template template) throws CRUDException {
		return templateMapper.findTotal(template);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param template
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(Template template) throws CRUDException {
		return templateMapper.findExTotal(template);
	}
	
	/**
	 * 数据新增
	 * @param template
	 * @throws CRUDException
	 */
	public void save(Template template) throws CRUDException{
		template.preInsert();
		templateMapper.save(template);
	}
	
	/**
	 * 数据修改
	 * @param template
	 * @throws CRUDException
	 */
	public void update(Template template) throws CRUDException{
		template.preUpdate();
		templateMapper.update(template);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		templateMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param template
	 * @throws CRUDException
	 */
	public void remove(Template template) throws CRUDException{
		template.preUpdate();
		templateMapper.remove(template);			
	}
	
}